#! /bin/bash

. ./scripts/shell/common.sh
. ./scripts/shell/golang.sh
. ./scripts/shell/tool.sh

PRE_HOOK="./scripts/hooks/pre-setup.sh"
END_HOOK="./scripts/hooks/end-setup.sh"

if [ -f ${PRE_HOOK} ];then
. ${PRE_HOOK}
fi

printShort "安装 githook"
cp -f .githooks/* .git/hooks/

# 检查工具是否存在 不存在则安装
printLong "工具安装"

toolCheckAndInstall ${GIT_CHGLOG} github.com/git-chglog/git-chglog/cmd/git-chglog
toolCheckAndInstall ${GSEMVER} github.com/arnaud-deprez/gsemver
toolCheckAndInstall ${YS_CLI} gitee.com/kmyss/ys-cli

# gf 框架要自己安装
printShort "检查 "  ${GF}
checkTool ${GF}
if [ $? != 0 ] 
then
    echo "请下载 " ${GF}
else
    echo "已安装 √"
fi

# git 框架要自己安装
printShort "检查 "  ${GIT}
checkTool ${GF}
if [ $? != 0 ]
then
    echo "请下载 " ${GIT} " https://git-scm.com/download"
else
    echo "已安装 √"
fi

if [ -f ${END_HOOK} ];then
. ${END_HOOK}
fi

if test -n "${HAS_WARNING}"
then
echo "注意安装中存在 WARNING 请检查!"
fi

